package com.gs.process.admin.utils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gs.process.model.dto.Constant;
import com.gs.process.model.Approval;
import com.gs.process.admin.service.ApprovalService;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author: Shuai Guo
 * @description:
 * @date: 2021/9/27
 * @version: 1.0
 */
public class ValidateUtil {

    public static boolean processCompletedByProcess(List<Long> ids, ApprovalService approvalService) {
        LambdaQueryWrapper<Approval> lambda = new LambdaQueryWrapper<>();
        lambda.in(Approval::getProcessId,ids).eq(Approval::getStatus, Constant.PROCESS_HANDLE_SIGN);
        return CollectionUtils.isEmpty(approvalService.list(lambda));
    }

    public static boolean processCompletedBySid(List<Long> ids, ApprovalService approvalService) {
        LambdaQueryWrapper<Approval> lambda = new LambdaQueryWrapper<>();
        lambda.in(Approval::getSid,ids).eq(Approval::getStatus, Constant.PROCESS_HANDLE_SIGN);
        return CollectionUtils.isEmpty(approvalService.list(lambda));
    }
}
